require "Reward"

QNW_TS_PerkXpReward = QNW_TS_Reward:derive("QNW_TS_PerkXpReward")

function QNW_TS_PerkXpReward:new(_perk, _num)
    local o = QNW_TS_Reward:new()
    setmetatable(o, self)
    self.__index = self

    o.num = _num
    o.perk = Perks[_perk]
    o.perkStr = _perk

    return o
end

function QNW_TS_PerkXpReward:getText()
    return self.perk:getName() .. getText("IGUI_XP_xp") .. "+" .. self.num
end

function QNW_TS_PerkXpReward:apply()
    getPlayer():getXp():AddXP(self.perk, self.num, true, false, false)
end

function QNW_TS_PerkXpReward:save()
    return { Type = self.Type, perkStr = self.perkStr, num = self.num }
end

function QNW_TS_PerkXpReward:load(_table)
    self.num = _table.num
    self.perk = Perks[_table.perkStr]
    self.perkStr = _table.perkStr
end